package cn.tedu.cwfw.fos.controller;

import cn.tedu.cwfw.base.response.JsonResult;
import cn.tedu.cwfw.fos.pojo.dto.FosQuery;
import cn.tedu.cwfw.fos.pojo.vo.FosVo;
import cn.tedu.cwfw.fos.service.FosService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cwfw/fos")
@Slf4j
public class FosController {
    @Autowired
    private FosService fosService;
//    增加店铺
    @RequestMapping("/addShop")
    public JsonResult addShop(FosVo fosVo){
        log.debug("增加店铺:{}",fosVo);
        fosService.addShop(fosVo);
        return JsonResult.ok();
    }

//    查看店铺信息
    @RequestMapping("/shop")
    public JsonResult findFos(FosQuery fosQuery){
        log.debug("查询店铺信息:{}",fosQuery);
        List<FosVo> fosVos = fosService.findFos(fosQuery);
        return JsonResult.ok(fosVos);
    }
//    删除店铺
    @RequestMapping("/deleteShop")
    public JsonResult deleteShop(Long id){
        log.debug("删除店铺:{}",id);
        fosService.delete(id);
        return JsonResult.ok();
    }
//    修改店铺信息
    @RequestMapping("/updateShop")
    public JsonResult updateShop(FosVo fosVo){
        log.debug("修改店铺信息:{}",fosVo);
        fosService.update(fosVo);
        return JsonResult.ok();
    }
//    根据id查看店铺
    @RequestMapping("/findById")
    public JsonResult findById(Long id){
        log.debug("根据id查看店铺:{}",id);
        FosVo fosVo = fosService.findById(id);
        return JsonResult.ok(fosVo);
    }
}
